<?php

declare(strict_types=1);
/**
 *  -----------------------------------------------------
 *  Created by : tool
 *  -----------------------------------------------------
 *
 *  -----------------------------------------------------
 *
 *  -----------------------------------------------------
 *  User: tf <1096392101@qq.com>
 *  -----------------------------------------------------
 */
namespace Gao\tool\helper;

class Str
{
    /**
     * 字符串截取.
     */
    public static function substr(string $str, int $start, int $length, string $encode = 'UTF-8'): string
    {
        return mb_substr($str, $start, $length, $encode);
    }

    /**
     * 字符串转小写.
     */
    public static function lower(string $value): string
    {
        return mb_strtolower($value, 'UTF-8');
    }

    /**
     * 字符串转大写.
     */
    public static function upper(string $value): string
    {
        return mb_strtoupper($value, 'UTF-8');
    }

    /**
     * 获取字符串的长度.
     */
    public static function length(string $value): int
    {
        return mb_strlen($value);
    }
}
